﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace JasLib.Collections
{
    /// <summary>
    /// This helps implement a list without cluttering the implementation with
    /// unused, redundant, or unnecessary interface functions.
    /// </summary>
    [Serializable]
    public abstract class SimplifiedListBase<T> : SimplifiedCollectionBase<T>, IList<T>, IList
    {
        public virtual int IndexOf(T item)
        {
            throw new NotImplementedException();
        }

        public virtual void Insert(int index, T item)
        {
            return;
        }

        public virtual void RemoveAt(int index)
        {
            throw new NotImplementedException();
        }

        public virtual T this[int index]
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void Insert(int index, object value)
        {
            throw new NotImplementedException();
        }

        public bool IsFixedSize
        {
            get { throw new NotImplementedException(); }
        }

        object IList.this[int index]
        {
            get
            {
                return (this as IList<T>)[index];
            }
            set
            {
                (this as IList<T>)[index] = (T)value;
            }
        }

        int IList.Add(object value)
        {
            (this as IList<T>).Add((T)value);
            return (Count - 1);
        }

        bool IList.Contains(object value)
        {
            if (value is T)
                return base.Contains((T)value);
            else
                return false;
        }

        int IList.IndexOf(object value)
        {
            return (this as IList<T>).IndexOf((T)value);
        }

        void IList.Insert(int index, object value)
        {
            (this as IList<T>).Insert(index, (T)value);
        }

        bool IList.IsFixedSize
        {
            get { return false; }
        }

        void IList.Remove(object value)
        {
            (this as IList<T>).Remove((T)value);
        }
    }
}
